package com.lkd.controller;

import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.VendingMachineService;
import com.lkd.vo.VendingMachineVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/vm-service/vm/search")
public class VendingMachineController {

    @Autowired
    private VendingMachineService vendingMachineService;

    /**
     * 分页查询设备
     * @param pageIndex
     * @param pageSize
     * @param innerCode
     * @return
     */
    @GetMapping
    public Result<PageBean<VendingMachineVo>> findByPage(
            @RequestParam(value = "pageIndex",defaultValue = "1") Integer pageIndex,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "innerCode", required = false) String innerCode
    ){
        PageBean<VendingMachineVo> pageBean = vendingMachineService.findByPage(pageIndex,pageSize,innerCode);
        return Result.success(pageBean);
    }
}
